import CustomModal from 'base/CustomModal/CustomModal'
import CustomTable from 'base/CustomTable/CustomTable'
import CustomPage from 'base/CustomPage/CustomPage'
import CustomFormItem from 'base/CustomFormItem/CustomFormItem'
import CustomInput from 'base/CustomInput/CustomInput'
import CustomCheckbox from 'base/CustomCheckbox/CustomCheckbox'
import CustomSelect from 'base/CustomSelect/CustomSelect'
import CustomDatePicker from 'base/CustomDatePicker/CustomDatePicker'
import CustomDrawer from 'base/CustomDrawer/CustomDrawer'
import CustomButton from 'base/CustomButton/CustomButton'
import SearchForm from 'base/SearchForm/SearchForm'
import Loading from 'base/Loading/Loading'
import TableButton from 'base/TableButton/TableButton'

const MyPlugin = {}
MyPlugin.install = function (app, options) {
  app.component('CustomModal', CustomModal)
  app.component('CustomTable', CustomTable)
  app.component('CustomPage', CustomPage)
  app.component('CustomFormItem', CustomFormItem)
  app.component('CustomInput', CustomInput)
  app.component('CustomCheckbox', CustomCheckbox)
  app.component('CustomSelect', CustomSelect)
  app.component('CustomDatePicker', CustomDatePicker)
  app.component('CustomDrawer', CustomDrawer)
  app.component('CustomButton', CustomButton)
  app.component('SearchForm', SearchForm)
  app.component('Loading', Loading)
  app.component('TableButton', TableButton)

  app.config.globalProperties.Static = '/static'

  window.SuccessMesaage = (str = '操作成功') => {
    return app.config.globalProperties.$Message.success(str)
  }

  window.ErrorMessage = (str = '操作失败', callback = () => {}) => {
    return app.config.globalProperties.$Message.error({
      content: str,
      duration: 3
    }, callback)
  }
}

export default MyPlugin
